home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / grafik / triton / demos / envprint / envprint.c < prev    next >
C/C++ Source or Header  |  1994-04-09  |  10KB  |  347 lines

  1. /*
  2.  *  Triton - The object oriented GUI creation system for the Amiga
  3.  *  Written by Stefan Zeiger in 1993-1994
  4.  *
  5.  *  (c) 1993-1994 by Stefan Zeiger
  6.  *  You are hereby allowed to use this source or parts of it for
  7.  *  creating programs for AmigaOS which use the Triton GUI creation
  8.  *  system. All other rights reserved.
  9.  *
  10.  *  envprint.c - Envprint 2.0 GUI created with Triton
  11.  *
  12.  *  As you can see below, it is possible to mix the tag format with
  13.  *  the C pre-processor macro format. (Actually I was just too lazy
  14.  *  to transform the whole project definition from tags to macros ;)
  15.  *
  16.  */
  17.  
  18.  
  19. #include <libraries/triton.h>
  20. #include <proto/triton.h>
  21. #include <proto/dos.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25.  
  26.  
  27. ProjectDefinition(main_trwintags)
  28. {
  29.   WindowID(1), WindowPosition(TRWP_CENTERDISPLAY), WindowBackfillFB,
  30.   WindowTitle("EnvPrint 2.0 <THIS IS ONLY A NON-FUNCTIONAL GUI DEMO>"),
  31.  
  32.   BeginMenu("Project"),
  33.     BeginSub("Load"),
  34.       SubItem("S_Load sender...",1),
  35.       SubItem("D_Load addressee...",2),
  36.       SubItem("C_Load comment...",3),
  37.     BeginSub("Save"),
  38.       SubItem("O_Load sender",4),
  39.       SubItem("E_Load addressee",5),
  40.       SubItem("M_Load comment",6),
  41.     BeginSub("Sace as"),
  42.       SubItem("U_Load sender as...",7),
  43.       SubItem("T_Load addressee as...",8),
  44.       SubItem("N_Load comment as...",9),
  45.     MenuItem("F_Delete file...",10),
  46.     ItemBarlabel,
  47.     MenuItem("P_Print...",11),
  48.     MenuItem("R_Preferences...",12),
  49.     ItemBarlabel,
  50.     MenuItem("?_About...",13),
  51.     ItemBarlabel,
  52.     MenuItem("Q_Quit",14),
  53.  
  54.   BeginMenu("Edit"),
  55.     MenuItem("W_Swap",15),
  56.     MenuItem("X_Clear",16),
  57.  
  58.   HorizGroupA,
  59.     Space,
  60.     VertGroupA,
  61.       HorizGroupEAC,
  62.         VertGroupA,
  63.  
  64.           Space,
  65.  
  66.           NamedSeparatorI("Se_nder",101),
  67.  
  68.           TROB_Space,         (ULONG) NULL,
  69.  
  70.           HorizGroup,
  71.             StringGadget(NULL,101),
  72.             HorizGroup|TRGR_FIXHORIZ,
  73.               GetEntryButtonS("_1",1101),
  74.               EndGroup,
  75.             EndGroup,
  76.  
  77.           SpaceS,
  78.  
  79.           HorizGroup,
  80.             StringGadget(NULL,102),
  81.             HorizGroup|TRGR_FIXHORIZ,
  82.               GetEntryButtonS("_2",1102),
  83.               EndGroup,
  84.             EndGroup,
  85.  
  86.           SpaceS,
  87.  
  88.           HorizGroup,
  89.             StringGadget(NULL,103),
  90.             HorizGroup|TRGR_FIXHORIZ,
  91.               GetEntryButtonS("_3",1103),
  92.               EndGroup,
  93.             EndGroup,
  94.  
  95.           TROB_Space,         (ULONG) TRST_SMALL,
  96.  
  97.           HorizGroup,
  98.             StringGadget(NULL,104),
  99.             HorizGroup|TRGR_FIXHORIZ,
  100.               GetEntryButtonS("_4",1104),
  101.               EndGroup,
  102.             EndGroup,
  103.  
  104.           TROB_Space,         (ULONG) TRST_SMALL,
  105.  
  106.           HorizGroup,
  107.             StringGadget(NULL,105),
  108.             HorizGroup|TRGR_FIXHORIZ,
  109.               GetEntryButtonS("_5",1105),
  110.               EndGroup,
  111.             EndGroup,
  112.  
  113.           TROB_Space,         (ULONG) TRST_SMALL,
  114.  
  115.           HorizGroup,
  116.             StringGadget(NULL,106),
  117.             HorizGroup|TRGR_FIXHORIZ,
  118.               GetEntryButtonS("_6",1106),
  119.               EndGroup,
  120.             EndGroup,
  121.  
  122.           TROB_Space,         (ULONG) TRST_SMALL,
  123.  
  124.           HorizGroup,
  125.             StringGadget(NULL,107),
  126.             HorizGroup|TRGR_FIXHORIZ,
  127.               GetEntryButtonS("_7",1107),
  128.               EndGroup,
  129.             EndGroup,
  130.  
  131.           TROB_Space,         (ULONG) TRST_SMALL,
  132.  
  133.           HorizGroup,
  134.             StringGadget(NULL,108),
  135.             HorizGroup|TRGR_FIXHORIZ,
  136.               GetEntryButtonS("_8",1108),
  137.               EndGroup,
  138.             EndGroup,
  139.  
  140.           TROB_Space,         (ULONG) NULL,
  141.  
  142.           TRGR_End,           (ULONG) NULL,
  143.  
  144.         TROB_Space,           (ULONG) NULL,
  145.  
  146.         TRGR_Vert,            (ULONG) TRGR_PROPSHARE|TRGR_ALIGN,
  147.  
  148.           TROB_Space,         (ULONG) NULL,
  149.  
  150.           NamedSeparatorI("Add_ressee",201),
  151.  
  152.           TROB_Space,         (ULONG) NULL,
  153.  
  154.           HorizGroup,
  155.             StringGadget(NULL,201),
  156.             HorizGroup|TRGR_FIXHORIZ,
  157.               GetEntryButtonS("_!",1201),
  158.               EndGroup,
  159.             EndGroup,
  160.  
  161.           SpaceS,
  162.  
  163.           HorizGroup,
  164.             StringGadget(NULL,202),
  165.             HorizGroup|TRGR_FIXHORIZ,
  166.               GetEntryButtonS("_\"",1202),
  167.               EndGroup,
  168.             EndGroup,
  169.  
  170.           SpaceS,
  171.  
  172.           HorizGroup,
  173.             StringGadget(NULL,203),
  174.             HorizGroup|TRGR_FIXHORIZ,
  175.               GetEntryButtonS("_§",1203),
  176.               EndGroup,
  177.             EndGroup,
  178.  
  179.           TROB_Space,         (ULONG) TRST_SMALL,
  180.  
  181.           HorizGroup,
  182.             StringGadget(NULL,204),
  183.             HorizGroup|TRGR_FIXHORIZ,
  184.               GetEntryButtonS("_$",1204),
  185.               EndGroup,
  186.             EndGroup,
  187.  
  188.           TROB_Space,         (ULONG) TRST_SMALL,
  189.  
  190.           HorizGroup,
  191.             StringGadget(NULL,205),
  192.             HorizGroup|TRGR_FIXHORIZ,
  193.               GetEntryButtonS("_\%",1205),
  194.               EndGroup,
  195.             EndGroup,
  196.  
  197.           TROB_Space,         (ULONG) TRST_SMALL,
  198.  
  199.           HorizGroup,
  200.             StringGadget(NULL,206),
  201.             HorizGroup|TRGR_FIXHORIZ,
  202.               GetEntryButtonS("_&",1206),
  203.               EndGroup,
  204.             EndGroup,
  205.  
  206.           TROB_Space,         (ULONG) TRST_SMALL,
  207.  
  208.           HorizGroup,
  209.             StringGadget(NULL,207),
  210.             HorizGroup|TRGR_FIXHORIZ,
  211.               GetEntryButtonS("_/",1207),
  212.               EndGroup,
  213.             EndGroup,
  214.  
  215.           TROB_Space,         (ULONG) TRST_SMALL,
  216.  
  217.           HorizGroup,
  218.             StringGadget(NULL,208),
  219.             HorizGroup|TRGR_FIXHORIZ,
  220.               GetEntryButtonS("_(",1208),
  221.               EndGroup,
  222.             EndGroup,
  223.  
  224.           TROB_Space,         (ULONG) NULL,
  225.  
  226.           TRGR_End,           (ULONG) NULL,
  227.  
  228.         TRGR_End,             (ULONG) NULL,
  229.  
  230.       NamedSeparatorI("Co_mment",301),
  231.  
  232.       TROB_Space,             (ULONG) NULL,
  233.  
  234.       HorizGroup,
  235.         StringGadget(NULL,301),
  236.         HorizGroup|TRGR_FIXHORIZ,
  237.           GetEntryButtonS("_0",1301),
  238.           EndGroup,
  239.         EndGroup,
  240.  
  241.       TROB_Space,             (ULONG) NULL,
  242.  
  243.       TRGR_End,               (ULONG) NULL,
  244.  
  245.     TROB_Space,               (ULONG) NULL,
  246.     TROB_Line,                (ULONG) TROF_VERT|TROF_RAISED,
  247.  
  248.     TROB_Space,               (ULONG) TRST_BIG,
  249.  
  250.     TRGR_Vert,                (ULONG) TRGR_PROPSHARE|TRGR_ALIGN|TRGR_FIXHORIZ,
  251.       TROB_Space,             (ULONG) NULL,
  252.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
  253.         TROB_Line,            (ULONG) TROF_HORIZ,
  254.         TROB_Space,           (ULONG) NULL,
  255.         TROB_Text,            (ULONG) NULL, TRAT_Text, (ULONG) "Load", TRAT_Flags, TRTX_3D,
  256.         TROB_Space,           (ULONG) NULL,
  257.         TROB_Line,            (ULONG) TROF_HORIZ,
  258.         TRGR_End,             (ULONG) NULL,
  259.       TROB_Space,             (ULONG) NULL,
  260.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Sender...", TRAT_ID, 501,
  261.       TROB_Space,             (ULONG) TRST_SMALL,
  262.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Addressee...", TRAT_ID, 502,
  263.       TROB_Space,             (ULONG) TRST_SMALL,
  264.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "_Comment...", TRAT_ID, 503,
  265.       TROB_Space,             (ULONG) NULL,
  266.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE|TRGR_CENTER,
  267.         TROB_Line,            (ULONG) TROF_HORIZ,
  268.         TROB_Space,           (ULONG) NULL,
  269.         TROB_Text,            (ULONG) NULL, TRAT_Text, (ULONG) "Save", TRAT_Flags, TRTX_3D,
  270.         TROB_Space,           (ULONG) NULL,
  271.         TROB_Line,            (ULONG) TROF_HORIZ,
  272.         TRGR_End,             (ULONG) NULL,
  273.       TROB_Space,             (ULONG) NULL,
  274.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "S_ender...", TRAT_ID, 504,
  275.       TROB_Space,             (ULONG) TRST_SMALL,
  276.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "A_ddressee...", TRAT_ID, 505,
  277.       TROB_Space,             (ULONG) TRST_SMALL,
  278.       TROB_Button,            (ULONG) NULL, TRAT_Text, (ULONG) "C_omment...", TRAT_ID, 506,
  279.       TROB_Space,             (ULONG) TRST_BIG,
  280.       TROB_Line,              (ULONG) TROF_HORIZ,
  281.       TROB_Space,             (ULONG) TRST_BIG,
  282.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE,
  283.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "_Print...", TRAT_ID, 507,
  284.         TROB_Space,           (ULONG) TRST_SMALL,
  285.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "S_wap", TRAT_ID, 508,
  286.         TRGR_End,             (ULONG) NULL,
  287.       TROB_Space,             (ULONG) TRST_SMALL,
  288.       TRGR_Horiz,             (ULONG) TRGR_EQUALSHARE,
  289.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "Pre_fs...", TRAT_ID, 509,
  290.         TROB_Space,           (ULONG) TRST_SMALL,
  291.         TROB_Button,          (ULONG) NULL, TRAT_Text, (ULONG) "C_lear", TRAT_ID, 510,
  292.         TRGR_End,             (ULONG) NULL,
  293.       TROB_Space,             (ULONG) NULL,
  294.     TRGR_End,                 (ULONG) NULL,
  295.  
  296.     TROB_Space,               (ULONG) NULL,
  297.  
  298.   TRGR_End,                   (ULONG) NULL,
  299.  
  300.   TAG_END
  301. };
  302.  
  303.  
  304. VOID do_main(VOID)
  305. {
  306.   BOOL close_me=FALSE;
  307.   struct TR_Project *main_project;
  308.   struct TR_Message *trmsg;
  309.  
  310.   if(main_project=TR_OpenProject(Application,main_trwintags))
  311.   {
  312.     while(!close_me)
  313.     {
  314.       TR_Wait(Application,NULL);
  315.       while(trmsg=TR_GetMsg(Application))
  316.       {
  317.         if(trmsg->trm_Project==main_project) switch(trmsg->trm_Class)
  318.         {
  319.           case TRMS_CLOSEWINDOW:
  320.             close_me=TRUE;
  321.             break;
  322.  
  323.           case TRMS_ERROR:
  324.             puts(TR_GetErrorString(trmsg->trm_Data));
  325.             break;
  326.         }
  327.         TR_ReplyMsg(trmsg);
  328.       }
  329.     }
  330.     TR_CloseProject(main_project);
  331.   }
  332. }
  333.  
  334.  
  335. int main(void)
  336. {
  337.   if(TR_OpenTriton(0,TRCA_Name,"Envprint",TRCA_LongName,"EnvPrint GUI demo",TRCA_Version,"2.0",TAG_END))
  338.   {
  339.     do_main();
  340.     TR_CloseTriton();
  341.     return 0;
  342.   }
  343.  
  344.   puts("Can't open triton.library.");
  345.   return 20;
  346. }
  347.